﻿using System;
using System.Web;

/// <summary>
/// 通用工具类
/// </summary>
public class Tools
{
	public Tools()
	{ }

    /// <summary> 
    /// 根据 Agent 判断是否是智能手机 
    /// </summary> 
    /// <returns></returns> 
    public static bool CheckAgent()
    {
        bool flag = false;
        string agent = HttpContext.Current.Request.UserAgent;
        string[] keywords = { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" };
        //排除Window 桌面系统 和 苹果桌面系统 
        if (!agent.Contains("Windows NT") && !agent.Contains("Macintosh"))
        {
            foreach (string item in keywords)
            {
                if (agent.Contains(item))
                {
                    flag = true;
                    break;
                }
            }
        }
        return flag;
    }
}
